<?php

/**
 * @author ThanhKhoaIT
 * @copyright 2013
 */

class Account
{
    public $UserID;
    public $UserName;
    public $Password;
    public $Email;
    public $FullName;
    public $Yahoo;
    public $Skype;
    public $Facebook;
    public $Phone;
    
    private $tablename = "ntk_account";
    private $columns = "userid,username,password,email,fullname,yahoo,skype,facebook,phone";
    
    protected function Get_($row)
    {
        $this->UserID   = $row["userid"];
        $this->UserName = $row["username"];
        $this->Password = $row["password"];
        $this->Email    = $row["email"];
        $this->FullName = $row["fullname"];
        $this->Yahoo    = $row["yahoo"];
        $this->Skype    = $row["skype"];
        $this->Facebook = $row["facebook"];
        $this->Phone    = $row["phone"];
    }
    
    protected function Set_()
    {
        $col = $this->Col_();
        $col["userid"]      = $this->UserID;
        $col["username"]    = $this->UserName;
        $col["password"]    = $this->Password;
        $col["email"]       = $this->Email;
        $col["fullname"]    = $this->FullName;
        $col["yahoo"]       = $this->Yahoo; 
        $col["skype"]       = $this->Skype;
        $col["facebook"]    = $this->Facebook;
        $col["phone"]       = $this->Phone;
        return $col;
    }
    
    protected function Where_($value)
    {
        return " Where userid = '$value' ";
    }
    
    protected function Col_()
    {
        $tmp = explode(",", $this->columns);
        $col = array();
        for ($i = 0; $i<count($tmp); $i++)
        {$col[$tmp[$i]] = "";}
        return $col;
    }
    
    function Get($id)
    {       
        $col = $this->Col_();
        $data = DB::select($this->tablename, $col, $this->Where_($id), "");
        if ($data != null)
        {
            $row = mysqli_fetch_array($data);
            $this->Get_($row);
        }
    }
    
    function Update()
    {
        $col = $this->Set_();
        DB::update($this->tablename, $col, $this->Where_($this->UserID));
    }
    
    function Insert()
    {
        $col = $this->Set_();
        DB::insert($this->tablename, $col);
    }
}
?>